
capture log close
clear all
set linesize 80
set more off

**********************************************************************
* Replication code 

* Purpose: This code generates figures and tables for the article,
* "Gendered perceptions of leadership and children's political ambition:
* Evidence from Nigeria", to be published in Politics, Groups, & Identities 

* Authors: Adebusola Okedele, Alice J. Kang, and Jill S. Greenlee

* Questions about the data? Please contact Dr. Kang at akang2@unl.edu

* Last updated: April 22, 2025
**********************************************************************

* Set the directory to where you stored the .dta file. 

* If the directory does not change, tables and graphs will be saved there.

* Start a log file
log using cpa_replication, replace text

* Version control
version 15.1
set seed 1234

* Open the dataset
use "cpa.dta", clear

******************************************************************************
* 						    Main Text in the Article						 *
******************************************************************************

***************************************
*  		Draw a Political Leader	      * 						  
***************************************
* Hypothesis 1
csgof drawman, expperc(50, 50)

* Figure 2, Panel A. Note that drawman2 includes drawings that were unclear
* or missing
tab drawman2

* Figure 2, Panel B
eststo clear 
mixed drawman i.girl##c.age know_scale || school: || class: 
	eststo drawman_g: margins, at(age=(5(1)16) girl=(1)) post vsquish
mixed drawman i.girl##c.age know_scale || school: || class: 
	eststo drawman_b: margins, at(age=(5(1)16) girl=(0)) post vsquish
	coefplot (drawman_b, label(Boys)) (drawman_g, label(Girls) lpattern(dash)) , ///
	xtitle ("Age") ///
	title ("") legend(rows(1) pos(6)) ///
	at recast(line) lwidth(*2) ciopts(recast(rarea) color(%20)) ///
	ylab(0 "0%" .25 "25%" .5 "50%" .75 "75%" 1 "100%", labsize(large)) ///
	xlab(5 "5" 6 "6" 7 "7" 8 "8" 9 "9" 10 "10" 11 "11" 12 "12" 13 "13" ///
	14 "14" 15 "15" 16 "16", labsize(large))  ///
	graphregion(color(white))
	graph save drawman.gph, replace
	graph export drawman.pdf, replace 

* Percent boys and girls who drew men
tab drawman if girl==0
tab drawman if girl==1

***************************************
*  		 Political Ambition  	      * 						  
***************************************
* See code for Table A3 for bivariate, difference of means tests

* Hypothesis 2
eststo clear 
eststo pol_H2: mixed poljob_prop girl age know_scale || school: || class: 
eststo pres_H2: mixed jobpres girl age know_scale job_total if job_total>=1 & job_total!=. || school: || class: 
eststo gov_H2: mixed jobgov girl age know_scale job_total if job_total>=1 & job_total!=. || school: || class: 
esttab pol_H2 pres_H2 gov_H2 using H2.rtf, ///
	nogap se b(%9.3f) starlevels(^ .10 * .05 ** .01 *** .001) bic ///
	nonumbers mtitle("Proportion of jobs in politics" "Choose president" "Choose governor") ///
	compress replace  
	
* Hypothesis 3
eststo clear 
eststo pol_H3: mixed poljob_prop i.girl##c.age know_scale || school: || class: 
eststo pres_H3: mixed jobpres i.girl##c.age know_scale job_total if job_total>=1 & job_total!=. || school: || class: 
eststo gov_H3: mixed jobgov i.girl##c.age know_scale job_total if job_total>=1 & job_total!=. || school: || class: 
esttab pol_H3 pres_H3 gov_H3 using H3.rtf, ///
	nogap se b(%9.3f) starlevels(^ .10 * .05 ** .01 *** .001) bic ///
	nonumbers mtitle("Proportion of jobs in politics" "Choose president" "Choose governor") ///
	compress replace  

* Figure 3, Panel A
eststo clear 
mixed poljob_prop i.girl##c.age know_scale || school: || class: 
	eststo jobs_g: margins, at(age=(5(1)16) girl =(1)) post vsquish
mixed poljob_prop i.girl##c.age know_scale || school: || class: 
	eststo jobs_b: margins, at(age=(5(1)16) girl =(0)) post vsquish
	coefplot (jobs_b, label(Boys)) (jobs_g, label(Girls) lpattern(dash)) , ///
	xtitle ("Age") ///
	title ("") legend(rows(1) pos(6)) ///
	at recast(line) lwidth(*2) ciopts(recast(rarea) color(%20)) ///
	ylab(0 "0%" .25 "25%" .5 "50%" .75 "75%" 1 "100%", labsize(large)) ///
	xlab(5 "5" 6 "6" 7 "7" 8 "8" 9 "9" 10 "10" 11 "11" 12 "12" 13 "13" ///
	14 "14" 15 "15" 16 "16", labsize(large)) graphregion(color(white)) 
	graph save propjobs.gph, replace
	graph export propjobs.pdf, replace 
 
* Figure 3, Panel B
eststo clear 
mixed jobpres i.girl##c.age know_scale job_total if job_total>=1 & job_total!=. || school: || class: 
	eststo pres_g: margins, at(age=(5(1)16) girl =(1)) post vsquish
mixed jobpres i.girl##c.age know_scale job_total if job_total>=1 & job_total!=. || school: || class: 
	eststo pres_b: margins, at(age=(5(1)16) girl =(0)) post vsquish
	coefplot (pres_b, label(Boys)) (pres_g, label(Girls) lpattern(dash)) , ///
	xtitle ("Age") ///
	title ("") legend(rows(1) pos(6)) ///
	at recast(line) lwidth(*2) ciopts(recast(rarea) color(%20)) ///
	ylab(0 "0%" .25 "25%" .5 "50%" .75 "75%" 1 "100%", labsize(large)) ///
	xlab(5 "5" 6 "6" 7 "7" 8 "8" 9 "9" 10 "10" 11 "11" 12 "12" 13 "13" ///
	14 "14" 15 "15" 16 "16", labsize(large)) graphregion(color(white)) 
	graph save pres.gph, replace
	graph export pres.pdf, replace 
 
* Figure 3, Panel C
eststo clear 
mixed jobgov i.girl##c.age know_scale job_total if job_total>=1 & job_total!=. || school: || class: 
	eststo gov_g: margins, at(age=(5(1)16) girl =(1)) post vsquish
mixed jobgov i.girl##c.age know_scale job_total if job_total>=1 & job_total!=. || school: || class: 
	eststo gov_b: margins, at(age=(5(1)16) girl =(0)) post vsquish
	coefplot (gov_b, label(Boys)) (gov_g, label(Girls) lpattern(dash)) , ///
	xtitle ("Age") ///
	title ("") legend(rows(1) pos(6)) ///
	at recast(line) lwidth(*2) ciopts(recast(rarea) color(%20)) ///
	ylab(0 "0%" .25 "25%" .5 "50%" .75 "75%" 1 "100%", labsize(large)) ///
	xlab(5 "5" 6 "6" 7 "7" 8 "8" 9 "9" 10 "10" 11 "11" 12 "12" 13 "13" ///
	14 "14" 15 "15" 16 "16", labsize(large)) graphregion(color(white)) 
	graph save gov.gph, replace
	graph export gov.pdf, replace 

******************************************************************************
* 				      		   Online Appendix		   				         *
******************************************************************************

* Children in private v. public schools
tab public

* % children who are 6 to 12 years old
gen bosage=1 if age>=6 & age<=12
replace bosage=0 if age<6 | age>12
replace bosage=. if age==.
tab bosage

* Table A1. Descriptive Statistics
mixed drawman i.girl##c.age know_scale || school: || class: 
gen sample1=e(sample)
sum drawman girl age know_scale if sample1==1

mixed poljob_prop i.girl##c.age know_scale || school: || class: 
gen sample2=e(sample)
sum poljob_prop if sample2==1

mixed jobpres girl age know_scale job_total if job_total>=1 & job_total!=. || school: || class:  
gen sample3=e(sample)
sum jobpres jobgov job_total if sample3==1

* Table A2. Draw a Man
eststo clear 
eststo draw_baseline: mixed drawman girl || school: || class: 
eststo draw_main: mixed drawman girl age know_scale || school: || class: 
eststo draw_interact: mixed drawman i.girl##c.age know_scale || school: || class: 
esttab draw_baseline draw_main draw_interact using draw.rtf, ///
	coeflabel(girl "Girl" age "Age" ///
	know_scale "Political knowledge" _cons "Constant") ///
	nogap se b(%9.3f) starlevels(^ .10 * .05 ** .01 *** .001) bic ///
	nonumbers mtitle("1" "2" "3") ///
	compress replace  

* Table A3. Bivariate Tests
ttest poljob_prop, by(girl) unequal
ttest jobpres, by(girl) unequal
ttest jobgov, by(girl) unequal

* Table A4. Additive Models
eststo clear 
eststo pol_main: mixed poljob_prop girl age know_scale || school: || class: 
eststo pres_main: mixed jobpres girl age know_scale job_total if job_total>=1 & job_total!=. || school: || class: 
eststo gov_main: mixed jobgov girl age know_scale job_total if job_total>=1 & job_total!=. || school: || class: 
esttab pol_main pres_main gov_main using main.rtf, ///
	coeflabel(girl "Girl" age "Age" ///
	know_scale "Political knowledge" job_total "Total jobs chosen" _cons "Constant") ///
	nogap se b(%9.3f) starlevels(^ .10 * .05 ** .01 *** .001) bic ///
	nonumbers mtitle("1" "2" "3") ///
	compress replace  
	
* Table A5. Multiplicative Models
eststo clear 
eststo pol_interact: mixed poljob_prop i.girl##c.age know_scale || school: || class: 
eststo pres_interact: mixed jobpres i.girl##c.age know_scale job_total if job_total>=1 & job_total!=. || school: || class: 
eststo gov_interact: mixed jobgov i.girl##c.age know_scale job_total if job_total>=1 & job_total!=. || school: || class: 
esttab pol_interact pres_interact gov_interact using interact.rtf, ///
	coeflabel(girl "Girl" age "Age" ///
	know_scale "Political knowledge" job_total "Total jobs chosen" _cons "Constant") ///
	nogap se b(%9.3f) starlevels(^ .10 * .05 ** .01 *** .001) bic ///
	nonumbers mtitle("1" "2" "3") ///
	compress replace  

* Table A6. Split Sample Analysis
eststo clear 
eststo pol_girl: mixed poljob_prop age know_scale if girl==1 || school: || class: 
eststo pol_boy: mixed poljob_prop age know_scale if girl==0 || school: || class: 
eststo pres_girl: mixed jobpres age know_scale job_total if girl==1 & job_total>=1 & job_total!=. || school: || class: 
eststo pres_boy: mixed jobpres age know_scale job_total if girl==0 & job_total>=1 & job_total!=. || school: || class: 
eststo gov_girl: mixed jobgov age know_scale job_total if girl==1 & job_total>=1 & job_total!=. || school: || class: 
eststo gov_boy: mixed jobgov age know_scale job_total if girl==0 & job_total>=1 & job_total!=. || school: || class: 
esttab pol_girl pol_boy pres_girl pres_boy gov_girl gov_boy using split.rtf, ///
	coeflabel(age "Age" ///
	know_scale "Political knowledge" job_total "Total jobs chosen" _cons "Constant") ///
	nogap se b(%9.3f) starlevels(^ .10 * .05 ** .01 *** .001) bic ///
	nonumbers mtitle("Prop. of jobs: Girls" "Prop. of jobs: Boys" "President: Girls" "President: Boys" "Governor: Girls" "Governor: Boys") ///
	compress replace  

log close
